﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;

namespace SuperSnake
{
    class Block
    {
        public Size size;//小方块大小
        public Color mycolor;//小方块颜色
        public Point location;//小方块位置
        public Block(Point loca)
        {
            size = new Size(GameField.blockWidth,GameField.blockWidth);
            mycolor = GameField.blockColor;
            location = loca;
        }
        /*画小方块*/
        public virtual void Draw(IntPtr winHandle)
        {
            Graphics g = Graphics.FromHwnd(winHandle);
            Rectangle r = new Rectangle(location, size);
            Rectangle r2 = new Rectangle(location, new Size(size.Width - 1, size.Height - 1));
            g.FillRectangle(new SolidBrush(mycolor), r);
            g.DrawRectangle(new Pen(new SolidBrush(Color.Black)), r2);
        }
        /*擦除方块*/
        public virtual void Erase(IntPtr winHandle)
        {
            Graphics g = Graphics.FromHwnd(winHandle);
            Rectangle r = new Rectangle(location, size);
            g.FillRectangle(new SolidBrush(GameField.backColor), r);
        }
    }
}
